<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>搜索</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../layer/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../css/topicList.css"/>
</head>
<body>
<div  id="topicList"></div>
<script src="../js/jquery.min.js"></script>
<!--<script src="../js/bootstrap.min.js"></script>-->
<script src="../js/common/inputTool.js"></script>
<script src="/myth/layer/layui.js" charset="utf-8"></script>
<script>
    $.get("../student/AlreadyChoose/a", function (data) {
        // console.log(data)
        // console.log(data.content)
        resultList = ''
        if (data.length === 0) {
            resultList = '<div class="none-title" style="margin-top: 60px;">暂无相关课题,快去选题吧</div>';
        } else {
            data.forEach(function (value) {
                resultList = resultList + '<div class="layui-collapse">' +
                    '<div class="layui-colla-item">' +
                    '    <h2 class="layui-colla-title">' + value.topicId.name + '<i class="layui-icon layui-colla-icon"></i></h2>' +
                    '    <div class="layui-colla-content">' +
                    '          <div class="list-item">' + value.topicId.attention + '</div><br/>' +
                    '          <button class="btn btn-primary showReply" data-id="'+value.topicId.topicId+'">查看教师回复</button>' +
                    // '          <button class="btn btn-danger cancelSelect"  data-id="'+value.topicId.topicId+'">取消选择</button>' +
                    '    </div>' +
                    '  </div>' +
                    '</div>'
            })
        }
        $("#topicList").html(resultList);//将上面拼接的HTML进行插入
        // $(".cancelSelect").on('click', function () {
        //     var id = $(this).data('id');
        //     console.log(id)
        // });
        $(".showReply").on('click', function () {
            var topicId = $(this).data('id');
            $.get('/myth/student/ReadReply/'+topicId, function (data) {
                // console.log(data.reply);
                result = '';
                teaName = data.topicId.guideId.name;
                if(data.reply == null){
                    result = teaName+' 教师还没回复你的申请'
                }else if(data.reply === '1'){
                    result = teaName+' 教师同意了你的申请, 并对你说: '+data.replyComment
                }else if(data.reply === '0'){
                    result = teaName+' 教师拒绝了你的申请, 并对你说: '+data.replyComment
                }else if(data.reply === '2'){
                    result = teaName+' 教师已经选了其他学生'
                }
                layer.msg(result)
            })
        });
        // 异步的执行 所以要在ajax中运行
        layui.use(['element', 'layer'], function () {
            // console.log("更新")
            var element = layui.element;
            element.init();
        });
    })

</script>
</body>
</html>